﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using System.Data.SqlClient;
using System.Data;

namespace DAO
{
    public class LoaiHoaDAO
    {
        public List<LoaiHoaDTO> LayDSLoaiHoa()
        {
            List<LoaiHoaDTO> dsLoaiHoa = new List<LoaiHoaDTO>();
            SqlConnection cn = DataProvider.ConnectionData();
            string sql = "sp_LayDanhSachLoaiHoa";
            SqlCommand cmd = new SqlCommand(sql, cn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataReader dr = cmd.ExecuteReader();
            LoaiHoaDTO loaihoa;
            while (dr.Read())
            {
                loaihoa = new LoaiHoaDTO();
                loaihoa.MaLoai = int.Parse(dr["MaLoai"].ToString());
                loaihoa.TenLoai = dr["TenLoai"].ToString();
                dsLoaiHoa.Add(loaihoa);
            }
            cn.Close();
            return dsLoaiHoa;
        }
    }
}
